#! /bin/sh

# Script to generate waveform quickly
# First argument should contain filename
fName="$1"
echo "Processing $fName"

# Analyze the design
echo "Command:    ghdl -a $fName"
ghdl -a $fName

# Get the module name, ie remove -behav if present
echo "Command:    echo $fName | sed 's/-behav//' | sed 's/.vhd//'"
tBench=$(echo $fName | sed 's/-behav//' | sed 's/.vhd/_tb/')
echo "Test bench is:   $tBench"

# Analyze, execute, and run the test bench
echo "Command:    ghdl -a $tBench.vhd"
ghdl -a $tBench.vhd
echo "Command:    ghdl -e $tBench"
ghdl -e $tBench
echo "Command:    ghdl -r $tBench --vcd=$tBench.vcd"
ghdl -r $tBench --vcd=$tBench.vcd
echo "Command:    gtkwave $tBench.vcd"
gtkwave $tBench.vcd
